// Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov  Date: 2009-10-26 21:59:36


// Source File Name:   LOOKUPSWITCH.java

package com.vhly.classfile.bytecode;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

// Referenced classes of package com.vhly.classfile.bytecode:
//            BaseCode

public class LOOKUPSWITCH
        implements BaseCode {

    private int offset;
    private int length;
    private int defaultV;
    private int npairs;
    private int jump;
    private int match_length;
    private int fixed_length;
    private int match[];
    private int indices[];

    public LOOKUPSWITCH() {
    }

    public String getName() {
        return "LOOKUPSWITCH";
    }

    public int getOp() {
        return 171;
    }

    public int length() {
        return length;
    }

    public void read(DataInputStream din)
            throws IOException {
        int ss = getOffset();
        int padding = (ss + 1 + 3 & -4) - ss - 1;
        for (int i = 0; i < padding; i++)
            din.read();

        defaultV = din.readInt();
        match_length = din.readInt();
        fixed_length = (short) (9 + match_length * 8);
        length = (short) (fixed_length + padding);
        match = new int[match_length];
        indices = new int[match_length];
        for (int i = 0; i < match_length; i++) {
            match[i] = din.readInt();
            indices[i] = din.readInt();
        }

    }

    public void write(DataOutputStream dout)
            throws IOException {
        int ss = getOffset();
        int padding = (ss + 1 + 3 & -4) - ss - 1;
        dout.write(171);
        for (int i = 0; i < padding; i++)
            dout.write(0);

        dout.writeInt(defaultV);
        dout.writeInt(match_length);
        for (int i = 0; i < match_length; i++) {
            dout.writeInt(match[i]);
            dout.writeInt(indices[i]);
        }

    }

    public int getDefault() {
        return defaultV;
    }

    public void setDefault(int def) {
        defaultV = def;
    }

    public int getBrenchSize() {
        return match.length;
    }

    public int[] getBrenchAt(int index) {
        int bs[] = new int[2];
        bs[0] = match[index];
        bs[1] = indices[index];
        return bs;
    }

    public void setBrenchAt(int pair[], int index) {
        match[index] = pair[0];
        indices[index] = pair[1];
    }

    public int getOffset() {
        return offset;
    }

    public String getDescrption() {
        String ret = "";
        return ret;
    }

    public void setOffset(int off) {
        offset = off;
    }
}